package com.spring.cloud.study.user.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * User: 齐丹枫
 * Date: 2018/3/30
 * Time: 9:18
 * To change this template use File | Settings | File Templates.
 * Description:
 */
@RestController
@RequestMapping("/api/sys/sysRole")
public class SysRoleController {
/*

    @Autowired
    private SysRoleService sysRoleService;
    @RequestMapping("/findRoleByUserName")
    public R findRoleByUserName(String username){
        return R.ok();
    }

    @RequestMapping("/findAll")
    public R findAll(){
        List<SysRole> sysRoles = sysRoleService.findAll();
        return R.ok().put("data",sysRoles);
    }

    @RequestMapping("/findRole")
    public R find(@RequestParam Map<String,Object> params){
        Page<SysRole> page = sysRoleService.findPage(params);
        List<SysRole> content = page.getContent();
       */
/* PropertyPreFilter preFilter = new PropertyPreFilter() {
            @Override
            public boolean apply(JSONSerializer jsonSerializer, Object o, String s) {
                if (s.equals("menus")) {
                    return false;
                }
                return true;
            }
        };*//*

        PageUtils pageUtils = new PageUtils(content,page.getTotalElements(),page.getNumberOfElements(),Integer.parseInt(params.get("page").toString()));
        return R.ok().put("data",pageUtils);
    }

    @RequestMapping("/deleteById")
    public R deleteById(@RequestParam int id){
        try {
            sysRoleService.delete(id);
        }catch (Exception e){
            R.error();
        }

        return R.ok();
    }


    @RequestMapping("/deleteBatchById")
    public R deleteBatchById(@RequestBody List<Integer> ids){
        sysRoleService.deleteBatch(ids);
        return R.ok();
    }



    @RequestMapping("/save")
    public R save(@RequestBody SysRole sysRole){
        sysRoleService.save(sysRole);
        return R.ok();
    }

    @RequestMapping("/update")
    public R update(@RequestBody SysRole sysRole){
        sysRoleService.save(sysRole);
        return R.ok();
    }

    @RequestMapping("/findById")
    public R findById(@RequestParam(value = "id") int id){
        SysRole sysRole = sysRoleService.findById(id);
        return  R.ok().put("data",sysRole);
    }


    @PostMapping("/saveRoleMenusById")
    public R saveRoleMenusById(@RequestBody Map<String,Object> params){
        Integer id =(Integer) params.get("id");
        List menuIds = (List) params.get("menuIds");
        sysRoleService.saveRoleMenusById(id,menuIds);
          return R.ok();
    }
*/


}
